"use client";
import "./index.css";
import { Avatar, Card, List, Typography } from "antd";
import Link from "next/link";
import TagList from "@/app/components/tagList";
import React from "react";

interface Props {
  questionList?: API.QuestionBankVO[];
  cardTitle?: React.ReactNode;
  questionBankId?: number;
}

/**
 * 题目列表组件
 * @param props
 * @constructor
 */
const QuestionList = (props: Props) => {
  const { questionList = [], cardTitle="", questionBankId } = props;

  return (
    <Card className="question-list" title={`${cardTitle}`}>
      <List
        dataSource={questionList}
        renderItem={(item) => (
          //@ts-ignore
          <List.Item extra={<TagList tagList={item.tagList} />}>
            <List.Item.Meta
              title={<Link href={questionBankId ? `/bank/${questionBankId}/question/${item.id}` : `/question/${item.id}`} target={"_blank"}>{item.title}</Link>}
            />
          </List.Item>
        )}
      />
    </Card>
  );
};

export default QuestionList;
